<?php
	require("frmCookie.php");
	
	$iOpcion = $_GET[iOpcion];
?>
<html>
	<head>
    	<?php
		require("frmHeader.php");
		?>
		<script language="javascript" src="scripts/ajax.js"></script>
		<script language="javascript" src="scripts/validar.js"></script>
		<script language="javascript">
		
		var xmlHttp;
		var option = 0;
		
		function showIMEI(str)
		{
			xmlHttp = GetXmlHttpObject();
			if (xmlHttp == null)
			{
				alert ("Your browser does not support AJAX!");
				return;
			}
			 
			var url = "ajaxOrden.php";
			url = url + "?part=" + str;
			url = url + "&op=24";
			url = url + "&q=" + frm.txtImei.value;
			url = url + "&sid=" + Math.random();
			xmlHttp.onreadystatechange = stateChangedIMEI;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
		}

		function stateChangedIMEI() 
		{ 
			if (xmlHttp.readyState == 4)
			{ 
				document.getElementById("txtHint").innerHTML = xmlHttp.responseText;
				if(xmlHttp.responseText == "")
				{
					document.frm.submit();
				}
			}
		}
		
		function valida()
		{
			
			if(frm.txtImei.value == "")
			{
				alert("Por favor ingrese el Imei o Serie.");
				frm.txtImei.focus();
				return false;
			}
			/*
			if(frm.txtImei.value != "")
			{
				if(IsNumeric(frm.txtImei.value) == false)
				{
					alert("El Imei solo puede contener numeros.");
					frm.txtImei.focus();
					return false;
				}
			}
			*/
			showIMEI("");
			
			return false;
		}
						
		</script>
	</head>
	<body>
    	<table cellpadding="0" cellspacing="0" align="center" class="tablaPrincipal">
        	<tr>
            	<td align="center">
                	<?php
					require("frmSession.php"); 
					
					//Redirecciona a SINPERMISOS.PHP en caso de no tener permisos
					switch ($iOpcion)
					{
						case 1:
						case 2:
						{
							if (!(in_array(47000, $_SESSION[permisos])))
							{
							?>
							  <script language="JavaScript" type="text/javascript">
							  <!--
							  window.location.href = "sinPermisos.php"
							  //-->
							  </script>
							<?php
							}
							$titulo = "Entrega de Ordenes EXPRESS";
							break;
						}
					}
					
					?>
                </td>
            </tr>
            <tr>
            	<td align="center">
                	<?php
					require("frmTitulo.php");
					?>
                </td>
            </tr>
            <?php 
            if($iOpcion != 2) 
        	{
            ?>
            <tr>
            	<td height="20">&nbsp;
                	
                </td>
            </tr>
            <tr>
            	<td align="center">
                	<table cellpadding="0" cellspacing="0" align="center" class="menuPrincipal">
                    	<tr>
                        	<td>
								<?php
                                require("frmMenu.php");
                                ?>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
            	<td height="20">&nbsp;
                	
                </td>
            </tr>
            <tr>
                <td align="center">
                	<table cellpadding="0" cellspacing="0" align="center" class="tituloPantalla">
                    	<tr>
                        	<td align="center">
                            	<p class="texto" align="left"><?php echo $titulo; ?></p>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
             <tr>
            	<td height="20">&nbsp;
                	
                </td>
            </tr>
            <tr>
                <td align="center">
                	<table cellpadding="0" cellspacing="0" align="center" class="estadoPantalla">
                    	<tr>
                        	<td align="center">
                            	<p class="texto" align="left"><?php echo $mensaje; ?></p>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
             <tr>
            	<td height="20">&nbsp;
                	
                </td>
            </tr>
            <?php 
        	}
            ?>
            <tr>
                <td align="center">
                	<table cellpadding="0" cellspacing="0" align="center" class="contenedorPrincipal">
                    	<tr>
                        	<td align="">
                				<form name="frm" action="impresionExpress.php?iOpcion=1&entregar=1" method="post" onSubmit="return valida();">
		                			<table>
		                				<tr>
		                					<td>Imei / Serie:</td>
		                					<td><input type="text" name="txtImei" size="20" maxlength="20" /></td><td colspan="2"><div id="txtHint"></div></td>
		                				</tr>
                                        <tr>
                                        	<td colspan="2">
                                            	Reducido:<input name="type" type="radio" value="short" checked/> Completo:<input name="type" type="radio" value="long"/>
                                            </td>
                                        </tr>
		                				<tr>
		                					<td colspan="2" align="center"><input type="button" name="cmdBuscar" value="Entregar" onClick="return valida();"></td>
		                				</tr>
		                			</table>
        		            	</form>
                           </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
	</body>
</html>